/*
-----------------------------------------------------------------------------
This file is part of escog.

Copyright (c) 2009 Jacob Essex

escog is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

escog is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with escog.  If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
*/

#include <fstream>
#include <string>
#include <map>

#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/map.hpp>

class Settings;
BOOST_CLASS_TRACKING(Settings, boost::serialization::track_never);

/**
* @brief auto saving/loading setup class. Only should be one instance...
*
* Simple interface for a std::map with auto loading and saving
*/
class Settings{
    std::map<std::string,std::string> mMap;

    friend class boost::serialization::access;
    template<class Archive>
    void serialize(Archive& ar, const unsigned int version){
        ar &mMap;
    }

    Settings(Settings&);
    static Settings* mInstance;
public:
    /**
    * @brief loads the settings file
    */
    Settings();
    ~Settings();

    inline void set(const std::string& k, const std::string& v){
        mMap[k] = v; //need insert
    }
    std::string get(const std::string& k) const;

	inline bool has(const std::string& k) const{
		return ( mMap.find(k) != mMap.end() );
	}

};
